﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.DirectoryServices;

namespace ex2l10_test1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }


        string initialName = "";
         
        

        private void groupName_TextChanged(object sender, EventArgs e)
        {
            if (groupNameTextBox.Text.Length > 0)
            {
                ds.Filter = "(&(objectclass=group)(cn=*" + groupNameTextBox.Text + "*))";
                //MessageBox.Show(ds.Filter.ToString());
                SearchResultCollection dsResults = ds.FindAll();
                ArrayList resultList = new ArrayList();

                foreach (SearchResult dsResult in dsResults)
                {
                   
                        groupNameTextBox.AutoCompleteCustomSource.Add(dsResult.Properties["cn"][0].ToString());
                }

                
            }
            assignmentNameTextBox.Text = initialName + "-" + groupNameTextBox.Text;
        }

        private void editAssignmentNameCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (editAssignmentNameCheckBox.Checked)
                assignmentNameTextBox.ReadOnly = false;
            else
                assignmentNameTextBox.ReadOnly = true;
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            initialName = assignmentNameTextBox.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form3.ActiveForm.Close();
        }

       
    }
}
